/**
 * This class was created by Nick Popescu to be used in Space Trader
 */
import java.io.Serializable;

/**
 * This class represents the Player of the game, who is an extension of a normal
 * Character.
 * 
 * @author Nick Popescu
 * @version 1.0
 */
public class Player extends Character implements Model, Serializable {
    
    /**
     * This represents how much money a player has 
     */
    private double wallet = 0;
    
    /**
     * This represents the current planet the player is on 
     */
    private Planet currentPlanet;

    /**
     * This class creates a new Player to be used in the space trader game 
     * @param name
     * @param skillDistrib
     */
    public Player(String name, int[] skillDistrib) {
	super(name, skillDistrib);
    }
    
    /**
     *This class creates a new Player to be used in the space trader game 
     */
    public Player(){
	this.wallet = 0;
    }
    
    /**
     * Creates a player with a given name and skill distributions. For the
     * purpose of the demo, prints out the newly-generated player's information.
     * 
     * @param name
     *            The name of the new player
     * @param initSkillTable
     *            The array of skill attributes that the player starts with.
     */
    @Override
    public void createPlayer(String name, int[] initSkillTable) {
	this.setName(name);
	this.setSkillArray(initSkillTable);
	this.setWallet(1000); // $codepro.audit.disable numericLiterals

	System.out.println("Player created! Your name is " + getName() + ".\n");
	System.out.println("Your skill distributions are: \n");
	for (int i = 0; i < initSkillTable.length; i++) {
	    System.out.print(getSkillNames()[i] + ": " + getSkillArray()[i]
		    + "\t");
	}
	System.out.println("You have " + getWallet() + " Gallactic Credits!");

    }

    /**
     * Assigns the given amount of currency to the player's wallet.
     * 
     * @param credits
     *            The given amount of currency that the player is given.
     */
    public void setWallet(double credits) {
	wallet = credits;
    }

    /**
     * Used to get the player's Wallet, which contains their money.
     * 
     * @return The wallet of the player, which is just the amount of money that
     *         they have.
     */
    public double getWallet() {
	return wallet;
    }

    /**
     * Assigns the given ship to the player.
     * 
     * @param ship
     *            The ship that is being assigned to the player.
     */
    @Override
    public void setPlayerShip(Ship ship) {
	this.setShip(ship);
	System.out.print("You were granted a " + getShip().getName()
		+ " Ship! Happy trading!\n");
    }

    /**
     * Used to get the player's ship.
     * 
     * @return The player's ship.
     */
    @Override
    public Ship getPlayerShip() {

	return getShip();
    }

    /**
     * Sets the current planet that the player is on.
     * 
     * @param planet
     *            The planet to be set as the Current Planet.
     */

    public void setCurrentPlanet(Planet planet) {
	this.currentPlanet = planet;
    }

    /**
     * Used to get the current planet that the player is on.
     * 
     * @return The current planet that the player is on.
     */
    public Planet getCurrentPlanet() {
	return currentPlanet;
    }
}
